const { userLogin } = require('../controller/user')
const { SuccessModel, ErrorModel } = require('../model/resModel')

const userHandleRouter = (req, res) => {
  if (req.method === 'POST' && req.path === '/api/user/login') {
    return userLogin(req.body).then(data => {
      if (data) {
        return new SuccessModel({}, '登录成功')
      } else {
        return new ErrorModel({}, '登录失败，用户名或者密码错误')
      }
    })
  }
}

module.exports = userHandleRouter
